# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator

from jms_dm_bi_day.depend.dwd_depend import jms_dwd__dwd_tab_barscan_collect_base_dt
from jms_dm_bi_day.depend.dwd_depend import jms_dwd__dwd_tab_barscan_return_msg_base_dt
from jms_dm_bi_day.depend.dwd_depend import jms_dwd__dwd_tab_barscan_deliver_base_dt
from jms_dm_bi_day.depend.dwd_depend import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
from jms_dm_bi_day.depend.dim_depend import jms_dim__dim_network_whole_massage
from jms_dm_bi_day.depend.dim_depend import jms_dim__dim_tab_agent_point_base
from jms_dm_bi_day.depend.dim_depend import jms_dim__dim_tab_terminal_secret_base
from jms_dm_bi_day.depend.ods_depend import jms_ods__project_work_order



dm__dm_network_end_dispatch_diff_detail = SparkSubmitOperator(
    task_id='dm__dm_network_end_dispatch_diff_detail',
    pool_slots=6,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='dm__dm_network_end_dispatch_diff_detail_{{ execution_date | date_add(1) | cst_ds }}',
    driver_memory='24G',
    executor_memory='10G',
    executor_cores=8,
    num_executors=40,
    retries=1,
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 4096,
          'spark.core.connection.ack.wait.timeout': 5000,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 120,
          'spark.driver.maxResultSize': 20,
          'spark.sql.shuffle.partitions': 1000,
          'spark.dynamicAllocation.maxExecutors': 60,  # 动态资源最大扩容 Executor 数
          },
    jars='hdfs:///scheduler/jms/spark/zyt/store_dispatch_data/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.export.ExportStoreDispatchData',
    application='hdfs:///scheduler/jms/spark/zyt/store_dispatch_data/StoreDispatchData.jar',
    application_args=['{{ execution_date | cst_ds }}'],
    execution_timeout=timedelta(minutes=120),
)

dm__dm_network_end_dispatch_diff_detail << [
    jms_dwd__dwd_tab_barscan_collect_base_dt,
    jms_dim__dim_tab_terminal_secret_base,
    jms_dwd__dwd_tab_barscan_return_msg_base_dt,
    jms_dwd__dwd_tab_barscan_deliver_base_dt,
    jms_ods__project_work_order,
    jms_dim__dim_tab_agent_point_base,
    jms_dim__dim_network_whole_massage,
    jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
]
